package com.headline.dbutil;

import com.headline.common.Log;
import org.apache.commons.dbutils.DbUtils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created with Administrator
 * DATE:2016/11/4
 * Time:16:43
 */
public class DbManager {
    private static Log log = Log.getLogger();

    private static String driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";

    private static String url = "jdbc:sqlserver://10.168.100.104:1433;databaseName=headline";
    private static String user = "sa";
    private static String password = "AutoDbps123";

//    private static String url = "jdbc:sqlserver://10.66.108.62:1433;databaseName=headline";
//    private static String user = "wz";
//    private static String password = "sa666666";

    /**
     * 获取数据库链接
     * 2016/11/4  16:50
     */
    public static Connection getConnection() {
        Connection conn = null;
        try {
            // Class.forName(driverClassName);
            DbUtils.loadDriver(driverClassName);
            conn = DriverManager.getConnection(url, user, password);

        } catch (SQLException e) {
            log.logger.error(e.getMessage());
            e.printStackTrace();
        }
        return conn;
    }
}
